<%@ page import="pojo.Label" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="dao.AddpowerDao" %>
<%@ page import="dao.impl.AddpowerDaoImpl" %>
<%@ page import="pojo.Addpower" %>
<%@ page import="service.LabelService" %>
<%@ page import="service.impl.LabelServiceImpl" %>
<%@ page import="pojo.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="script/jquery-3.3.1.js"></script>
<html>
<style>
    *{
        margin: 0px;
        padding: 0px;
        box-sizing: border-box;
    }
    .title{
        margin: auto;
    }
    .bac_border{
        width: 500px;
        height:700px;
        border: 8px solid #EEEEEE;
        margin: auto;
        padding: 15px;
    }
    .left{
        width: 80px;
        text-align: right;
        height: 80px;
    }
    #title{
        width: 290px;
        height: 43px;
        border: 1px solid #A6A6A6;
        border-radius: 5px;
        padding-left: 10px;
    }
    #content{
        width: 290px;
        height: 250px;
        /*height: 300px;*/
        border: 1px solid #A6A6A6;
        border-radius: 5px;
        padding-left: 10px;
    }
    #submit,#cancle{
        width: 100px;
        height: 30px;
        background-color:lightskyblue;
        align-content: center;
        border: 1px solid lightskyblue;
    }
    #submit{
        margin-right: 20px;
    }
    .end{
        margin-top: 80px;
        margin-bottom: 20px;
    }
    #content{
        width: 290px;
        height: 300px;
        border: 1px solid #A6A6A6;
        border-radius: 5px;
        padding-left: 10px;
    }
</style>
<head>
    <title>Title</title>
</head>
<body>
<%
    int uid= Integer.parseInt(request.getParameter("uid"));
    AddpowerDao addpowerDao=new AddpowerDaoImpl();
    ArrayList<Addpower> list=addpowerDao.findUserPower(uid);
    request.setAttribute("list",list);
    int a=0;
    int b=0;int c=0;int d=0;int e=0;int f=0;int g=0;
    request.setAttribute("a",a);
    request.setAttribute("b",b);
    request.setAttribute("c",c);
    request.setAttribute("d",d);
    request.setAttribute("e",e);
    request.setAttribute("f",f);
    String usename= (String) session.getAttribute("usename");
    request.setAttribute("usename",usename);
    User userLogin= (User) session.getAttribute("userLogin");
    request.setAttribute("userLogin",userLogin);
    LabelService labelService=new LabelServiceImpl();
    ArrayList<Label> allLabels=new ArrayList<>();
    allLabels=labelService.allLabels();
    request.setAttribute("allLabels",allLabels);
%>
<div class="bac_border">
    <div class="title1"><p class="word" align="center">发布新笔记</p></div>
    <form action="${pageContext.request.contextPath}/noteServlet?action=addNote&usename=${usename}&uid=${userLogin.uid}" method="post">
        <table class="table">
            <tr class="title">
                <td class="left"><label for="title">标题</label></td>
                <td class="right"><input type="text" name="title" id="title" placeholder="请输入标题"></td>
            </tr>

<%--            图片：<input type="file" name="photo" ><br>--%>

            <tr>
                <td class="left"><label >区域</label></td>
                <c:forEach items="${list}" var="addpower" varStatus="s">
                    <c:if test="${addpower.mid==1}">
                        <input type="hidden" value="${a=1}">
                    </c:if>
                    <c:if test="${addpower.mid==2}">
                        <input type="hidden" value="${b=1}">
                    </c:if>
                    <c:if test="${addpower.mid==3}">
                        <input type="hidden" value="${c=1}">
                        <c:if test="${addpower.mid==4}">
                            <input type="hidden" value="${d=1}">
                        </c:if>
                        <c:if test="${addpower.mid==5}">
                            <input type="hidden" value="${e=1}">
                        </c:if>
                        <c:if test="${addpower.mid==6}">
                            <input type="hidden" value="${f=1}">
                        </c:if>
                    </c:if>
                </c:forEach>
                <td class="td_bottom">
                    <c:if test="${a==0}">
                        <input type="radio" name="type" value="游戏区" > 游戏区
                    </c:if>
                    <c:if test="${a==1}">
                        <input type="radio" name="type" value="游戏区" disabled> 游戏区
                    </c:if>
                    <c:if test="${b==0}">
                        <input type="radio" name="type" value="萌宠区" placeholder="请选择区域"> 萌宠区
                    </c:if>
                    <c:if test="${b==1}">
                        <input type="radio" name="type" value="萌宠区" placeholder="请选择区域" disabled> 萌宠区
                    </c:if>
                    <c:if test="${c==0}">
                        <input type="radio" name="type" value="美食区" placeholder="请选择区域"> 美食区
                    </c:if>
                    <c:if test="${c==1}">
                        <input type="radio" name="type" value="美食区" placeholder="请选择区域" disabled> 美食区
                    </c:if>
                    <c:if test="${d==0}">
                        <input type="radio" name="type" value="体育区" placeholder="请选择区域"> 体育区
                    </c:if>
                    <c:if test="${d==1}">
                        <input type="radio" name="type" value="体育区" placeholder="请选择区域" disabled> 体育区
                    </c:if>
                    <c:if test="${e==0}">
                        <input type="radio" name="type" value="动漫区" placeholder="请选择区域"> 动漫区
                    </c:if>
                    <c:if test="${e==1}">
                        <input type="radio" name="type" value="动漫区" placeholder="请选择区域" disabled> 动漫区
                    </c:if>
                    <c:if test="${f==0}">
                        <input type="radio" name="type" value="风景区" placeholder="请选择区域"> 风景区
                    </c:if>
                    <c:if test="${f==1}">
                        <input type="radio" name="type" value="风景区" placeholder="请选择区域" disabled> 风景区
                    </c:if>
                </td>
            </tr>
            <tr class="content">
                <td class="left"><label for="content">内容</label></td>
                <td class="right"><input type="content" name="content" id="content" placeholder="内容"></td>
            </tr>
            <p id="labels" name="labels">推荐标签：</p>
            <br>
            <c:forEach items="${allLabels}" var="label" varStatus="s">
                <input type="checkbox" name="check" id="check" value="${label.label}">${label.label}
            </c:forEach>
            <br>
            <span>自定义标签：</span>
            <ul>

            </ul>
            <input type="text" id="userLabel" name="userLabel">
            <input type="button" value="添加" id="userAdd">
            <script>
                document.getElementById("userAdd").onclick=function() {
                    var labelcontent=$("#userLabel").val();
                    var ul = document.getElementsByTagName("ul")[0];
                    $("#userLabel").val("")
                    ul.innerHTML+='<input type="checkbox" name="userAddLabel" id="userAddLabel" checked value="'+labelcontent+'">'+labelcontent+'&nbsp&nbsp';
                }
            </script>
            <div class="end" align="center" colspan="3" >
    <a href="${pageContext.request.contextPath}/pageServlet?usename=${usename}&action=userNotePage">取消</a>
                <input type="submit" id="submit" value="提交">
            </div>
        </table>
    </form>
</div>
</body>
</html>


